local ClientOHOH = _G.ClientOHOH
local M = ClientOHOH.class.new(script,ClientOHOH.files.OHOHOLYBUIBase())
local CallBackManager =  ClientOHOH.load.CallBackManager()
local ConnectClass = _G.CommonOHOH.load.Connect()
local FunctionList = ClientOHOH.load.FunctionList();

function M.new(...)
    return M(...)
end

function Initsts(ui)
    ui.insts = {}
    ui.insts.root = "ctrl.root"
    ui.insts.Close = "ctrl.close"
    ui.insts.scGui = "ctrl.screenGui"
end


function M.ctor(self)
    Initsts(self)
    M.super.ctor(self,ClientOHOH:GetPath_Loop("ReplicatedStorage.Resource.UI.GoldenPetGui"))
    self.BuyEvent = ConnectClass.new()
    self.DatabaseReadyEvent = ConnectClass.new()
    self.PetSelectedEvent = ConnectClass.new()
    self.isShowEvent = ConnectClass.new()
    self.isHundredPercentEvent = ConnectClass.new()
    self.MakeSuccessEvent = ConnectClass.new()
    self.gamepassBuyDoneEvent = ConnectClass.new()
    self.MakeEvent = ConnectClass.new()
    --初始化点击，让从其他窗口跳转过来可以传petid直接选中
    self.InitSelectEvent = ConnectClass.new()

    CallBackManager:AddRbxConnect(self,self.insts.Close.Activated,function()
		self:Hide()
	end)
    self.insts.scGui:GetPropertyChangedSignal("Enabled"):Connect(function()
        self.isShowEvent:Action(self.insts.scGui.Enabled)
    end)

    self:Init()
end

function M.Init(self)
    self.GoldenPetList = require(script.petList)
    self.Craft  = require(script.Craft)
    self.GoldenPetList.new(self)
    self.Craft.new(self)
end

function M.SetDataBase(self,dataBase)
    self.DataBase=dataBase
    self.DatabaseReadyEvent:Action()
end

function M.UpdateCraftUi(self)
    self.Craft:UpdateUi()
    self.Craft:CheckBuyDone()
end

function M.UpdateListGui(self)
    self.MakeSuccessEvent:Action()
end

function M.dtor(self)
    M.super.dtor(self)
end

------------------------对外调用接口-----------------------------------------
-- 获取玩家数据库
function M.GetDataBase(self)
    return self.DataBase
end

function M.SetMakeProbability(self,prob)
    -- print("setMakeProb",prob)
    self.Craft.SetProbability(prob)
end



return M